package com.smart.common.enums;

/**
 * 设备操作命令枚举
 */
public enum DeviceActionEnum {

    REMOTE_LOCATION(128, "远程立即定位"),
    REMOTE_HEART_RATE(127, "远程测量心率"),
    REMOTE_SHUTDOWN(121, "远程关机"),
    REMOTE_BLOOD_PRESSURE(120, "远程测量血压"),
    REMOTE_TEMPERATURE(117, "远程测量体温"),
    SEND_VOICE_TO_WATCH(118, "下发语音到手表"),
    SEND_TEXT_TO_WATCH(115, "下发文字信息到手表"),
    REMOTE_OXYGEN(119, "远程测量血氧"),
    SEND_BLOOD_PRESSURE_RESULT(152, "下发血压学习后的测量结果给设备"),
    SET_DO_NOT_DISTURB_TIME(140, "设置免打扰时间"),
    REMOTE_RESTART(141, "远程设备重启"),
    SEND_TWO_DIMENSIONAL_INFO(142, "下发二维信息到设备"),
    SET_PedomETER_WORK_TIME(143, "设置计步器工作时间"),
    SEND_HEART_ATTACK_WARNING(144, "下发心梗预警信息"),
    SEND_BRAIN_ATTACK_WARNING(145, "下发脑梗预警信息"),
    SEDENTARY_REMINDER(146, "久坐提醒设置"),
    SLEEP_TIME_SETTING(147, "睡眠时间设置"),
    SET_BLUETOOTH_SCAN_PARAMS(148, "设置蓝牙扫描参数"),
    FACTORY_RESET(90, "恢复出厂设置"),
    SET_HEALTH_MEASUREMENT_BIAS(103, "设置测量健康时的偏差参数"),
    SEND_GLUCOSE_LEARNING_COMMAND(161, "下发血糖学习指令"),
    SEND_GLUCOSE_MEASUREMENT_COMMAND(162, "下发血糖测量指令"),
    QUICK_DIAL_COMMAND(163, "快捷拨号指令"),
    FIND_DEVICE(164, "查找设备");

    private final int code;
    private final String description;

    DeviceActionEnum(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    /**
     * 根据代码获取枚举实例
     *
     * @param code 操作代码
     * @return 枚举实例
     */
    public static DeviceActionEnum fromCode(int code) {
        for (DeviceActionEnum action : values()) {
            if (action.getCode() == code) {
                return action;
            }
        }
        throw new IllegalArgumentException("Unsupported code: " + code);
    }
}